#include "libgit2_init.h"

libgit2_init::libgit2_init(QWidget* parent)
    : QWidget(parent)
{
}

int libgit2_init::init(const char* path)
{
    git_libgit2_init();
    git_repository* rep = nullptr;
    // git init
    int error = git_repository_init(&rep, path, 0);
    if (error < 0) {
        const git_error* e = giterr_last();
        std::cout << "Error: " << error << " / " << e->klass << " : " << e->message << std::endl;
        goto SHUTDOWN;
    }
SHUTDOWN:
    git_repository_free(rep);
    git_libgit2_shutdown();
    return 0;
}
